package com.flame.core.mybatis;

import java.util.Collection;

/**
 *
 *
 * @author wuxintong
 * @since 2022/9/11
 */
public class PageBody<T> {

    private int pageNum;

    private int pageSize;

    private int pages;

    private long total;

    private Collection<? extends T> list;

    public PageBody() {
    }

    public PageBody(Collection<? extends T> pageList) {
        if (pageList instanceof PageList) {
            PageList page = (PageList) pageList;
            this.pageNum = page.getPageNum();
            this.pageSize = page.getPageSize();
            this.pages = page.getPages();
            this.total = page.getTotal();
        } else {
            this.pageNum = 0;
            this.pageSize = 0;
            this.pages = 0;
            this.total = pageList.size();
        }
        this.list = pageList;
    }

    public int getPageNum() {
        return pageNum;
    }

    public void setPageNum(int pageNum) {
        this.pageNum = pageNum;
    }

    public int getPageSize() {
        return pageSize;
    }

    public void setPageSize(int pageSize) {
        this.pageSize = pageSize;
    }

    public int getPages() {
        return pages;
    }

    public void setPages(int pages) {
        this.pages = pages;
    }

    public long getTotal() {
        return total;
    }

    public void setTotal(long total) {
        this.total = total;
    }

    public Collection<? extends T> getList() {
        return list;
    }

    public void setList(Collection<? extends T> list) {
        this.list = list;
    }
}

